package com.lightkits.wms.util.models;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.lightkits.common.db.entity.sysmessage.SysMessageBase;
import com.lightkits.common.db.entity.sysmessage.SysMessageTl;
import com.lightkits.framework.common.exception.LightKitsBizException;
import org.springframework.stereotype.Service;

/**
 * @author jing.wei@hand-china.com
 * @date 2019/6/1 15:50
 **/
public class MessUtil {

    public static String getMessage(String code) {
        SysMessageBase messageBase = new SysMessageBase().selectOne(new EntityWrapper()
                .eq(SysMessageBase.MESSAGE_CODE, code));
        if (messageBase == null) {
            throw new LightKitsBizException("the code is invalid ");
        }
        SysMessageTl messageTl = new SysMessageTl().selectOne(new EntityWrapper()
                .eq(SysMessageTl.MESSAGE_ID, messageBase.getId()));
        return messageTl.getMessageText();
    }
}
